<extend name="Public/common" />
<block name="style">
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/common.css">
</block>
<block name="body">
    <div class="am-g admin">
        <div class="am-u-lg-10 am-u-lg-offset-1">
            <div class="am-g">
                <ol class="am-breadcrumb">
                    <li><a href="{:U('Admin/Index/index')}" class="am-icon-home">首页</a></li>
                    <li class="am-active">用户管理</li>
                </ol>
            </div>
            <div class="am-g">
                <div class="am-u-lg-10">
                    <div style="float: right">
                        <form class="am-form-inline" role="form">
                            <div class="am-form-group">
                                <input type="text" name="nickname" value="{:I('nickname')}" class="am-form-field" placeholder="昵称">
                            </div>
                            <button type="submit" class="am-btn am-btn-primary">查询</button>
                        </form>
                    </div>
                </div>
            </div>
            <br>
            <div class="am-g">
                <div class="am-u-lg-10">
                    <table class="am-table am-table-bordered am-table-striped am-table-hover">
                        <thead>
                        <tr>
                            <th>头像</th>
                            <th>昵称</th>
                            <th>注册时间</th>
                            <th>身份</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                            <volist name="_userList" id="uvo">
                                <tr class="">
                                    <td>
                                        <img src="{$uvo['head_pic_url']}" style="width: 50px;height: 50px">
                                    </td>
                                    <td>{$uvo['nickname']}</td>
                                    <td>{:date('Y-m-d H:i',$uvo['create_time'])}</td>
                                    <td>{:user_status_str($uvo['status'])}</td>
                                    <td>
                                        <switch name="uvo['status']">
                                            <case value="99" break="1">
                                                <a class="am-btn disabled" href="javascript:;">系统管理员不可操作</a>
                                            </case>
                                            <case value="-1" break="1">
                                                <a class="status-btn am-btn am-btn-xs am-btn-danger" data-status="0" data-user-id="{$uvo['user_id']}">恢复</a>
                                            </case>
                                            <case value="0" break="1">
                                                <a class="status-btn am-btn am-btn-xs am-btn-success" data-status="1" data-user-id="{$uvo['user_id']}">通过审核</a>
                                                &nbsp;
                                                <a class="status-btn am-btn am-btn-xs am-btn-danger" data-status="-1" data-user-id="{$uvo['user_id']}">禁用</a>
                                            </case>
                                            <case value="1" break="1">
                                                <a class="status-btn am-btn am-btn-xs am-btn-primary" data-status="2" data-user-id="{$uvo['user_id']}">设置为社工</a>
                                                &nbsp;
                                                <a class="status-btn am-btn am-btn-xs am-btn-danger" data-status="-1" data-user-id="{$uvo['user_id']}">禁用</a>
                                            </case>
                                            <case value="2" break="1">
                                                <a class="status-btn am-btn am-btn-xs am-btn-warning" data-status="1" data-user-id="{$uvo['user_id']}">解除社工</a>
                                                &nbsp;
                                                <a class="status-btn am-btn am-btn-xs am-btn-danger" data-status="-1" data-user-id="{$uvo['user_id']}">禁用</a>
                                            </case>
                                        </switch>
                                    </td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-lg-10 my-page">
                    {$_html}
                </div>
            </div>
        </div>
    </div>
</block>
<block name="script">
    <script>
        var loading;
        $(function(){
            $('.status-btn').click(function(){
                loading = layer.load();
                var obj = $(this);
                var param = {
                    status:obj.attr('data-status'),
                    user_id:obj.attr('data-user-id')
                }
                var url = "{:U('Admin/User/setStatus')}";
                $.post(url,param,function(res){
                    layer.close(loading);
                    res = JSON.parse(res);
                    if(res.status == 1){
                        layer.msg(res.info,{icon: 1});
                        setTimeout("window.location.href=''",1500);
                    }else{
                        layer.msg(res.info);
                    }
                });
            });
        });
    </script>
</block>